package com.stjb.furns.web;

import com.stjb.furns.entity.Member;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author situ
 * @version 1.0
 * @date 2025/5/26 23:01
 * @Description:
 */
public class AdminServlet extends BasicServlet {

    protected void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //登录
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        // System.out.println(username+"\t"+password);
        if ("admin".equals(username) && "admin".equals(password) ) {//登录成功
            //保存到Session
            Member member = new Member(999, "admin", "admin", "admin@qq.com");
            request.getSession().setAttribute("member",member);
            //转发
            request.getRequestDispatcher("/views/manage/manage_menu.jsp").forward(request, response);
        }else {
            request.setAttribute("msg","用户名或者密码错误");
            request.getRequestDispatcher("/views/manage/manage_login.jsp").forward(request,response);
        }

    }


}
